package com.bykj.property.mapper.provider;

import com.bykj.property.controller.vo.request.DoorCardPageRequest;
import com.bykj.property.controller.vo.request.NewsSendPageRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.jdbc.SQL;

/**
 * @author yiming
 * @title: NewsSendSql
 * @projectName property
 * @description: TODO
 * @date 2019/6/2921:27
 */
public class NewsSendSql {
    public String getSql(NewsSendPageRequest pageRequest){
        return new SQL() {
            {
                SELECT("*");
                FROM("news_send");
                if(!StringUtils.isEmpty(pageRequest.getTitle())) {
                    pageRequest.setTitle("%"+pageRequest.getTitle()+"%");
                    WHERE("title like #{title}");
                }
                if(!StringUtils.isEmpty(pageRequest.getPulisher())) {
                    pageRequest.setPulisher("%"+pageRequest.getPulisher()+"%");
                    WHERE("pulisher like #{pulisher}");
                }
                if(!StringUtils.isEmpty(pageRequest.getSummary())) {
                    pageRequest.setSummary("%"+pageRequest.getSummary()+"%");
                    WHERE("summary like #{summary}");
                }




            }
        }.toString();

    }
}
